/*
 * @Author: tanjunyi@doctorwork.com
 * @Date: 2020-06-21 10:55:57
 * @LastEditors: tanjunyi@doctorwork.com
 * @LastEditTime: 2020-06-21 11:05:19
 * @Description:
 */
/**
 * 创建文本节点
 * @param {*} text 
 */
export function createTextVNode(text) {
	return vnode(undefined, undefined, undefined, undefined, text);
}

export function createElement(tag, data = {}, ...children) {
	let key = data.key;
	if (key) {
		delete data.key;
	}
	// vue中的key不会作为属性传递给子组件
	return vnode(tag, data, key, children)
}

/**
 * 生成虚拟节点
 * @param {*} tag 
 * @param {*} data 
 * @param {*} key 
 * @param {*} children 
 * @param {*} text 
 */
function vnode(tag, data, key, children, text) {
	return {
		tag,
		data,
		key,
		children,
		text
	}
}